Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var e = require("../@babel/runtime/helpers/classCallCheck"), t = require("../@babel/runtime/helpers/createClass"), o = function() {
    function o() {
        e(this, o), this.loginInfo = {}, this.systemInfo = {};
    }
    return t(o, [ {
        key: "getWxCode",
        value: function() {
            wx.login({
                success: function(e) {
                    console.log(e), e.code || console.log("登录失败！" + e.errMsg);
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        }
    }, {
        key: "getSystemInfo",
        value: function() {
            try {
                this.systemInfo = wx.getSystemInfoSync();
                var e = wx.getMenuButtonBoundingClientRect();
                if (e.top <= 0 || e.height <= 0) -1 != this.systemInfo.system.indexOf("Android") ? this.systemInfo.titleHeight = 48 : this.systemInfo.titleHeight = 44; else {
                    var t = e.top - this.systemInfo.statusBarHeight;
                    this.systemInfo.titleHeight = 2 * t + e.height;
                }
                this.systemInfo.titleBarTotalHeight = this.systemInfo.titleHeight + this.systemInfo.statusBarHeight, 
                this.systemInfo.safeAreaHeight = this.systemInfo.screenHeight - this.systemInfo.safeArea.bottom;
            } catch (e) {
                console.log(e);
            }
        }
    }, {
        key: "setLoginInfo",
        value: function(e) {
            wx.setStorageSync("loginInfo", e), this.loginInfo = e;
        }
    }, {
        key: "removeLoginInfo",
        value: function() {
            wx.setStorageSync("loginInfo", {}), this.loginInfo = {};
        }
    }, {
        key: "isLogin",
        value: function() {
            return !!this.loginInfo.id;
        }
    }, {
        key: "loginThenRedirectTo",
        value: function(e) {
            var t, o = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0;
            this.isLogin() ? e && wx.navigateTo({
                url: e,
                fail: function() {
                    wx.switchTab({
                        url: e
                    });
                }
            }) : (t = e ? "/pages/login/login?fromUserID=".concat(n, "&redirectTo=").concat(encodeURIComponent(e)) : "/pages/login/login?fromUserID=".concat(n), 
            o ? wx.redirectTo({
                url: t,
                fail: function() {
                    wx.switchTab({
                        url: t
                    });
                }
            }) : wx.navigateTo({
                url: t,
                fail: function() {
                    wx.switchTab({
                        url: t
                    });
                }
            }));
        }
    } ]), o;
}();

exports.default = o;